{% extends "_layout.html" %}

{# 样式代码 #}
{% block style %}
    <link href="/css/plugins/iCheck/custom.css" rel="stylesheet">
{% endblock %}

{# bodyd代码#}
{% block body %}
    <div class="wrapper wrapper-content">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">

                    <div class="ibox-content">
                        <div class="row">
                            <div class="col-sm-2">
                                <div class="input-group">
                                    <input type="text" placeholder="手机号" class="input-sm form-control" />
                                </div>
                            </div>
                            <div class="col-sm-2">
                                <div class="input-group">
                                    <input type="text" placeholder="姓名" class="input-sm form-control"> <span class="input-group-btn">
                            <button type="button" class="btn btn-sm btn-primary"> 搜索</button> </span>
                                </div>
                            </div>
                            <div class="ibox-tools">
                                <a href="/user/edit" class="btn btn-primary btn-xs">创建新项目</a>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="table-responsive">
                            <table class="table table-striped">
                                <thead>
                                <tr>
                                    <th></th>
                                    <th>项目</th>
                                    <th>进度</th>
                                    <th>任务</th>
                                    <th>日期</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for item in data.list %}
                                    <tr>
                                        <td>
                                            <input type="checkbox" checked class="i-checks" name="input[]">
                                        </td>
                                        <td class="image">
                                            <a href="projects.html"><img alt="image" class="image" src="{{item.avatar}}"></a>
                                        </td>
                                        <td>{{item.name}}</td>
                                        <td><span class="pie">{{item.mobile}}</span>
                                        </td>
                                        <td>{{item.email}}</td>
                                        <td>{{item.createTime}}</td>
                                        <td>
                                            <a class="del" data-href="/user/delete?id={{item.id}}">删除</a>
                                            <a href="/user/edit?id={{item.id}}">编辑</a>
                                        </td>
                                    </tr>
                                {% else %}
                                    暂无数据
                                {% endfor %}
                                </tbody>
                            </table>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="text-right">
                            <div class="btn-group">
                                <p>第{{data.pageNo}}页,共{{data.totalPage}}页
                                    {% if data.firstPage %}
                                        <a href="javascript:void(0);" class="btn btn-white disable" type="button"><i class="fa fa-chevron-left"></i></a>
                                    {% else %}
                                        <a href="/user?pageNo={{data.pretPage}}" class="btn btn-white" type="button"><i class="fa fa-chevron-left"></i></a>
                                    {% endif %}
                                    {% if data.lastPage %}
                                        <a href="javascript:void(0);" class="btn btn-white" type="button"><i class="fa fa-chevron-right"></i></a>
                                    {% else %}
                                        <a href="/user?pageNo={{data.nextPage}}" class="btn btn-white" type="button"><i class="fa fa-chevron-right"></i></a>
                                    {% endif %}
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
{% endblock %}

{#js代码#}
{% block js %}
    <script>
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
        });

        $(function () {
            $(".del").on("click", function () {
                var url = $(this).data("href");
                layer.confirm('你确定要删除?', {icon: 3, title:'提示'}, function(index){
                    $.ajax({
                        url: url,
                        dataType: 'json',
                        type: 'post',
                        success: function (data) {
                            if (data.code == 200){
                                window.location.reload();
                            }
                        }
                    });
                    layer.close(index);
                });
            });
        });


    </script>

{% endblock %}
